package com.yuanluludev.app.room.student

import com.yuanluludev.app.room.AppDataBaseHelper
import com.yuanluludev.lib_utils.util.LogUtils

object StudentHelper {

    private val studentDao by lazy { AppDataBaseHelper.appDatabase.getStudentDao() }

    /**
     * 插入一个学生
     */
    suspend fun insertStudent(student: Student) {
        val index = studentDao.insertStudent(student)
        LogUtils.e("插入返回值 = $index")
    }

    /**
     * 插入一部分学生
     */
    suspend fun insertStudents(vararg students: Student) {
        studentDao.insertStudents(*students)
    }

    /**
     * 查询所有学生
     */
    suspend fun getAllStudent() = studentDao.queryAllStudent()

    /**
     * 查询所有学生
     */
    suspend fun queryStudentLikeName(nameLike:String) = studentDao.queryStudentLikeName(nameLike)

    /**
     * 查询学生  根据ID
     */
    suspend fun queryStudentByUid(uid:Long) = studentDao.queryStudentByUid(uid)

    /**
     * 查询所有学生 根据uid降序查询
     */
    suspend fun queryAllStudentOrderByUidDesc() = studentDao.queryAllStudentOrderByUidDesc()

    /**
     * 根据学生id删除
     */
    suspend fun deleteStudentByID(uid: Long) = studentDao.deleteStudentByID(uid)

    /**
     * 更新学生
     */
    suspend fun updateStudent(student: Student) = studentDao.updateStudent(student)

}